﻿using PeoplesJukebox.Web.ServiceClients.Bases;

namespace PeoplesJukebox.Web.ServiceClients
{
    /// <summary>
    /// Client class for media catalogue services
    /// </summary>
    public class CatalogueServiceClient : ServiceClientBase
    {
        /// <summary>
        /// Returns the service base address
        /// </summary>
        protected override string BaseAddress
        {
            //get { return string.Format("http://{0}/PeoplesJukebox.Services/CatalogueService.svc/", ServiceHost.HostName); }
            get { return "/PeoplesJukebox.Services/CatalogueService.svc/"; }
        }

        /// <summary>
        /// Start asynchronous media item search
        /// </summary>
        /// <param name="searchTerm">Search term</param>
        public void Search(string searchTerm)
        {
            //only search for >1 character:
            if (searchTerm.Length > 1)
            {
                StartDownload("any/{0}", searchTerm);
            }
        }

        /// <summary>
        /// Start asynchronous call to get tracks for artist
        /// </summary>
        /// <param name="artistId">Artist ID</param>
        public void GetArtistTracks(int artistId)
        {
            StartDownload("tracks/artist/{0}", artistId);
        }

        /// <summary>
        /// Start asynchronous call to get tracks for album
        /// </summary>
        /// <param name="albumId">Album ID</param>
        public void GetAlbumTracks(int albumId)
        {
            StartDownload("tracks/album/{0}", albumId);
        }

        /// <summary>
        /// Start asynchronous call to get all artists
        /// </summary>
        public void GetArtists()
        {
            StartDownload("artists");
        }

        /// <summary>
        /// Start asynchronous call to search artists
        /// </summary>
        /// <param name="artistName">Name to search</param>
        public void SearchArtists(string artistName)
        {
            StartDownload("artists/{0}", artistName);
        }

        /// <summary>
        /// Start asynchronous call to get all albums
        /// </summary>
        public void GetAlbums()
        {
            StartDownload("albums");
        }

        /// <summary>
        /// Start asynchronous call to search albums
        /// </summary>
        /// <param name="albumName">Name to search</param>
        public void SearchAlbums(string albumName)
        {
            StartDownload("albums/{0}", albumName);
        }

        /// <summary>
        /// Start asynchronous call to get all tracks
        /// </summary>
        public void GetTracks()
        {
            StartDownload("tracks");
        }

        /// <summary>
        /// Start asynchronous call to search tracks
        /// </summary>
        /// <param name="trackName">Name to search for</param>
        public void SearchTracks(string trackName)
        {
            StartDownload("tracks/{0}", trackName);
        }

        /// <summary>
        /// Start asynchronous call to get track suggestions
        /// </summary>
        public void GetTrackSuggestions()
        {
            StartDownload("tracks/random/6");
        }
    }
}